{% extends 'base.html' %}

{% block content %}
    <br>
    <span>总记录数: {{topic_count}}</span>
    <br>
    <span><a href="/post/topic_add/">新增话题</a></span>
    <br>
    <hr>
    <table border="1">
       <tr>
           <td>编号</td>
           <td>标题</td>
           <td>话题内容</td>
           <td>创建日期</td>
       </tr>
       {% for topic in page_obj %}
       <tr>
           <td>{{topic.pk}}</td>
           <td><a href="/post/topic/{{topic.id}}/">{{topic.title | slice:10 }}...</a></td>
           <td>{{topic.content | slice:20}}...</td>
           <td>{{topic.created_time}}</td>
       </tr>
       {% empty %}
       <tr>
           <td colspan="4">没有记录返回</td>
       </tr>
       {% endfor %}
    </table>
    <hr>
    <!--分页功能-->
    <div>
       <span>
           {% if page_obj.has_previous %}
               <a href="{% url 'topic_list_page' 1 %}">首页</a>
               <a href="{% url 'topic_list_page' page_obj.previous_page_number %}">上一页</a>
           {% endif %}
           <span>
               第{{page_obj.number}}页/共{{page_obj.paginator.num_pages}}页
           </span>
           {% if page_obj.has_next %}
               <a href="{% url 'topic_list_page' page_obj.next_page_number %}">下一页</a>
               <a href="{% url 'topic_list_page' page_obj.paginator.num_pages %}">末页</a>
           {% endif %}
       </span>
    </div>

{% endblock %}